package net.sf.rose.business.bean.control;

import java.util.ArrayList;
import java.util.List;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Default;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

/**
 * @author fengjian
 * @since 2014-5-20
 */
@Default
@Root(name = "view")
public class ViewBean {

	/** 名称 */
	@Attribute
	private String name = null;

	/** 标题 */
	@Attribute
	private String text = null;

	/** 分类 */
	@Attribute(required = false)
	private String sort = null;

	/** 路径 */
	@Attribute(required = false)
	private String path = null;

	/** 视图说明 */
	@Attribute(required = false)
	private String description = null;

	/** 视图的所有页签 */
	@ElementList(name = "tabs", required = false)
	private List<TabBean> tabs = new ArrayList<TabBean>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<TabBean> getTabs() {
		return tabs;
	}

	public void setTabs(List<TabBean> tabs) {
		this.tabs = tabs;
	}

	public TabBean getTab(String text) {
		for (TabBean bean : tabs) {
			if (bean.getText().equals(text)) {
				return bean;
			}
		}
		return null;
	}

	public void removeTab(String name) {
		for (TabBean bean : tabs) {
			if (bean.getText().equals(text)) {
				tabs.remove(bean);
				return;
			}
		}
	}

}
